/************************************************************
   Copyright 2008 Abhinav Pobbati

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*************************************************************/

#include "HkPrerequisites.h"

#include "Havok4Xna/Common/Base/Math/HkVector4.h"
#include "Havok4Xna/Common/Base/Math/HkMatrix3.h"
#include "Havok4Xna/Common/Base/Math/HkQuaternion.h"
#include "Havok4Xna/Common/Base/Math/HkTransform.h"
#include "Havok4Xna/Common/Base/Math/HkQsTransform.h"

namespace Havok4Xna {
	void HkVector4Comparison::SetAnd(HkVector4Comparison ^a, HkVector4Comparison ^b) {
		_this()->setAnd(a->_ref(), b->_ref());
	}
	void HkVector4Comparison::Set(HkVector4Comparison::Mask m) {
		_this()->set((hkVector4Comparison::Mask) m);
	}
	hkBool32 HkVector4Comparison::AllAreSet(HkVector4Comparison::Mask m) {
		return _this()->allAreSet((hkVector4Comparison::Mask) m);
	}
	hkBool32 HkVector4Comparison::AnyIsSet(HkVector4Comparison::Mask m) {
		return _this()->anyIsSet((hkVector4Comparison::Mask) m);
	}
	hkBool32 HkVector4Comparison::AllAreSet() {
		return _this()->allAreSet();
	}
	hkBool32 HkVector4Comparison::AnyIsSet() {
		return _this()->anyIsSet();
	}
	int HkVector4Comparison::GetMask() {
		return _this()->getMask();
	}
	int HkVector4Comparison::GetMask(HkVector4Comparison::Mask m) {
		return _this()->getMask((hkVector4Comparison::Mask) m);
	}


	HkVector4::HkVector4(float x, float y, float z, float w) {
		_setThis(new hkVector4(x, y, z, w), true);
	}
	HkVector4::HkVector4(float value) {
		_setThis(new hkVector4(value, value, value, value), true);
	}
	HkVector4::HkVector4(Vector3 vector) {
		_setThis(new hkVector4(vector.X, vector.Y, vector.Z, 0), true);
	}
	HkVector4::HkVector4(Vector4 vector) {
		_setThis(new hkVector4(vector.X, vector.Y, vector.Z, vector.W), true);
	}
	HkVector4::HkVector4(HkVector4 ^vector) {
		_setThis(new hkVector4(vector->_ref()), true);
	}
	float HkVector4::X::get() {
		return _ref()(0);
	}
	void HkVector4::X::set(float val) {
		_ref()(0) = val;
	}
	float HkVector4::Y::get() {
		return _ref()(1);
	}
	void HkVector4::Y::set(float val) {
		_ref()(1) = val;
	}
	float HkVector4::Z::get() {
		return _ref()(2);
	}
	void HkVector4::Z::set(float val) {
		_ref()(2) = val;
	}
	float HkVector4::W::get() {
		return _ref()(3);
	}
	void HkVector4::W::set(float val) {
		_ref()(3) = val;
	}
	void HkVector4::Set(float x, float y, float z) {
		_this()->set(x, y, z);
	}
	void HkVector4::Set(float x, float y, float z, float w) {
		_this()->set(x, y, z, w);
	}
	void HkVector4::SetAll(float val) {
		_this()->setAll(val);
	}
	void HkVector4::SetAll3(float val) {
		_this()->setAll3(val);
	}
	void HkVector4::SetZero4() {
		_this()->setZero4();
	}
	void HkVector4::Add4(HkVector4 ^v) {
		_this()->add4(v->_ref());
	}
	void HkVector4::Add3ClobberW(HkVector4 ^v) {
		_this()->add3clobberW(v->_ref());
	}
	void HkVector4::SetAdd4(HkVector4 ^a, HkVector4 ^b) {
		_this()->setAdd4(a->_ref(), b->_ref());
	}
	void HkVector4::Sub4(HkVector4 ^v) {
		_this()->sub4(v->_ref());
	}
	void HkVector4::Sub3ClobberW(HkVector4 ^v) {
		_this()->sub3clobberW(v->_ref());
	}
	void HkVector4::SetSub4(HkVector4 ^a, HkVector4 ^b) {
		_this()->setSub4(a->_ref(), b->_ref());
	}
	void HkVector4::Mul4(HkVector4 ^a) {
		_this()->mul4(a->_ref());
	}
	void HkVector4::SetMul4(HkVector4 ^a, HkVector4 ^b) {
		_this()->setMul4(a->_ref(), b->_ref());
	}
	void HkVector4::Mul4(float a) {
		_this()->mul4(a);
	}
	void HkVector4::SetMul4(float a, HkVector4 ^b) {
		_this()->setMul4(a, b->_ref());
	}
	void HkVector4::AddMul4(float a, HkVector4 ^b) {
		_this()->addMul4(a, b->_ref());
	}
	void HkVector4::SubMul4(float a, HkVector4 ^b) {
		_this()->subMul4(a, b->_ref());
	}
	void HkVector4::SetAddMul4(HkVector4 ^a, HkVector4 ^b, float r) {
		_this()->setAddMul4(a->_ref(), b->_ref(), r);
	}
	void HkVector4::SetAddMul4(HkVector4 ^a, HkVector4 ^b, HkVector4 ^c) {
		_this()->setAddMul4(a->_ref(), b->_ref(), c->_ref());
	}
	void HkVector4::SetCross(HkVector4 ^a, HkVector4 ^b) {
		_this()->setCross(a->_ref(), b->_ref());
	}
	void HkVector4::SetInterpolate4(HkVector4 ^a, HkVector4 ^b, float r) {
		_this()->setInterpolate4(a->_ref(), b->_ref(), r);
	}
	hkBool32 HkVector4::Equals3(HkVector4 ^a, float epsilon) {
		return _this()->equals3(a->_ref(), epsilon);
	}
	hkBool32 HkVector4::Equals4(HkVector4 ^a, float epsilon) {
		return _this()->equals4(a->_ref(), epsilon);
	}
	HkVector4Comparison ^HkVector4::CompareLessThan4(HkVector4 ^v) {
		return gcnew HkVector4Comparison(&_this()->compareLessThan4(v->_ref()), false);
	}
	HkVector4Comparison ^HkVector4::CompareEqual4(HkVector4 ^v) {
		return gcnew HkVector4Comparison(&_this()->compareEqual4(v->_ref()), false);
	}
	HkVector4Comparison ^HkVector4::CompareLessThanEqual4(HkVector4 ^v) {
		return gcnew HkVector4Comparison(&_this()->compareLessThanEqual4(v->_ref()), false);
	}
	HkVector4Comparison ^HkVector4::CompareLessThanZero4() {
		return gcnew HkVector4Comparison(&_this()->compareLessThanZero4(), false);
	}
	HkVector4Comparison ^HkVector4::CompareGreaterThan4(HkVector4 ^v) {
		return gcnew HkVector4Comparison(&_this()->compareGreaterThan4(v->_ref()), false);
	}
	HkVector4Comparison ^HkVector4::CompareGreaterThanEqual4(HkVector4 ^v) {
		return gcnew HkVector4Comparison(&_this()->compareGreaterThanEqual4(v->_ref()), false);
	}
	hkBool32 HkVector4::AllLessThan3(HkVector4 ^v) {
		return _this()->allLessThan3(v->_ref());
	}
	hkBool32 HkVector4::AllLessThan4(HkVector4 ^v) {
		return _this()->allLessThan4(v->_ref());
	}
	void HkVector4::SetNeg3(HkVector4 ^v) {
		_this()->setNeg3(v->_ref());
	}
	void HkVector4::SetNeg4(HkVector4 ^v) {
		_this()->setNeg4(v->_ref());
	}
	void HkVector4::SetAbs4(HkVector4 ^v) {
		_this()->setAbs4(v->_ref());
	}
	void HkVector4::SetMin4(HkVector4 ^a, HkVector4 ^b) {
		_this()->setMin4(a->_ref(), b->_ref());
	}
	void HkVector4::SetMax4(HkVector4 ^a, HkVector4 ^b) {
		_this()->setMax4(a->_ref(), b->_ref());
	}
	void HkVector4::SetMul3(HkMatrix3 ^m, HkVector4 ^v) {
		_this()->setMul3(m->_ref(), v->_ref());
	}
	void HkVector4::SetRotatedDir(HkRotation ^r, HkVector4 ^v) {
		_this()->setRotatedDir(r->_ref(), v->_ref());
	}
	void HkVector4::SetRotatedInverseDir(HkRotation ^r, HkVector4 ^v) {
		_this()->setRotatedInverseDir(r->_ref(), v->_ref());
	}
	void HkVector4::SetTransformedPos(HkTransform ^t, HkVector4 ^v) {
		_this()->setTransformedPos(t->_ref(), v->_ref());
	}
	void HkVector4::SetTransformedInversePos(HkTransform ^t, HkVector4 ^v) {
		_this()->setTransformedInversePos(t->_ref(), v->_ref());
	}
	void HkVector4::SetTransformedPos(HkQsTransform ^t, HkVector4 ^v) {
		_this()->setTransformedPos(t->_ref(), v->_ref());
	}
	void HkVector4::SetTransformedInversePos(HkQsTransform ^t, HkVector4 ^v) {
		_this()->setTransformedInversePos(t->_ref(), v->_ref());
	}
	float HkVector4::Dot3(HkVector4 ^v) {
		return _this()->dot3(v->_ref());
	}
	float HkVector4::Dot3Fpu(HkVector4 ^v) {
		return _this()->dot3fpu(v->_ref());
	}
	float HkVector4::Dot4(HkVector4 ^v) {
		return _this()->dot4(v->_ref());
	}
	float HkVector4::Dot4xyz1(HkVector4 ^v) {
		return _this()->dot4xyz1(v->_ref());
	}
	float HkVector4::HorizontalAdd3() {
		return _this()->horizontalAdd3();
	}
	float HkVector4::HorizontalAdd4() {
		return _this()->horizontalAdd4();
	}
	float HkVector4::Length3() {
		return _this()->length3();
	}
	float HkVector4::LengthSquared3() {
		return _this()->lengthSquared3();
	}
	float HkVector4::LengthInverse3() {
		return _this()->lengthInverse3();
	}
	float HkVector4::DistanceTo3(HkVector4 ^v) {
		return _this()->distanceTo3(v->_ref());
	}
	float HkVector4::Length4() {
		return _this()->length4();
	}
	float HkVector4::LengthSquared4() {
		return _this()->lengthSquared4();
	}
	float HkVector4::LengthInverse4() {
		return _this()->lengthInverse4();
	}
	void HkVector4::Normalize3() {
		_this()->normalize3();
	}
	float HkVector4::NormalizeWithLength3() {
		return _this()->normalizeWithLength3();
	}
	void HkVector4::Normalize4() {
		_this()->normalize4();
	}
	float HkVector4::NormalizeWithLength4() {
		return _this()->normalizeWithLength4();
	}
	void HkVector4::FastNormalize3() {
		_this()->fastNormalize3();
	}
	float HkVector4::FastNormalizeWithLength3() {
		return _this()->fastNormalizeWithLength3();
	}
	void HkVector4::FastNormalize3NonZero() {
		_this()->fastNormalize3NonZero();
	}
	HkResult HkVector4::Normalize3IfNotZero() {
		return (HkResult) _this()->normalize3IfNotZero();
	}
	void HkVector4::SetXYZW(HkVector4 ^v1, HkVector4 ^v2) {
		_this()->setXYZW(v1->_ref(), v2->_ref());
	}
	void HkVector4::SetW(HkVector4 ^v) {
		_this()->setW(v->_ref());
	}
	void HkVector4::SetXYZ(HkVector4 ^v) {
		_this()->setXYZ(v->_ref());
	}
	void HkVector4::SetXYZ0(HkVector4 ^v) {
		_this()->setXYZ0(v->_ref());
	}
	void HkVector4::SetReciprocal4(HkVector4 ^v) {
		_this()->setReciprocal4(v->_ref());
	}
	void HkVector4::SetReciprocal3(HkVector4 ^v) {
		_this()->setReciprocal3(v->_ref());
	}
	void HkVector4::SetSqrtInverse4(HkVector4 ^v) {
		_this()->setSqrtInverse4(v->_ref());
	}
	int HkVector4::GetMajorAxis() {
		return _this()->getMajorAxis();
	}
	bool HkVector4::IsOk3() {
		return _this()->isOk3();
	}
	bool HkVector4::IsOk4() {
		return _this()->isOk4();
	}
	bool HkVector4::IsNormalized3(float eps) {
		return _this()->isNormalized3(eps);
	}
	bool HkVector4::IsNormalized4(float eps) {
		return _this()->isNormalized4(eps);
	}
}
